<%@ page import="org.gtesoreria.ConsultaAfiliadosController" %>
<%@ page import="org.gtesoreria.Proveedor" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'proveedor.label', default: 'Proveedor')}" />
        <title><g:message code="default.show.label" args="[entityName]" /></title>
		<modalbox:modalIncludes />
    </head>
    <body>
        <div class="nav" style="display:none">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1>Importar Consumos</h1>
            <g:if test="${flash.message}">
            	<div class="message">${flash.message}</div>
            </g:if>
            <g:if test="${mensaje}">
            	<div class="errors">${mensaje}</div>
            </g:if>

             <div style="float:left; margin-left:5px;">
	                <g:form action="importarConsumosByName" method="post" enctype="multipart/form-data">
	                 <div style="padding:5px">
	                 <input type="file" name="myFile" id="file"/>
	                	<g:submitButton name="upload" value="Importar" id="upload"></g:submitButton>
	                </div>
	                <div style="padding:5px">
	                <g:checkBox name="isFarmacia" id="isFarmacia"></g:checkBox> El proveedor es una Farmacia
	                </div>
	                <div style="padding:5px">
	                	Porcentaje de Subsidio en medicamentos: <g:textField name="porcSubsidio" value="${porcSubsidio}" size="3"/>%
	                </div>
	                </g:form>
           		</div>
            
            <g:if test="${consumosImportados != null }">
            
            <div class="list" style="float:left; margin-left:5px;clear:both">
             <h2>Consumos Importados:</h2>
                <table>
                    <thead>
                        <tr>
                        
                            <th>${message(code: 'consumo.consumo.label', default: 'Consumo')} </th>
                        
                            <th><g:message code="consumo.afiliado.label" default="Afiliado" /></th>
                        
                            <th>${message(code: 'consumo.periodo.label', default: 'Periodo')} </th>
                        
                            <th>${message(code: 'consumo.monto.label', default: 'Monto')} </th>
                            
                            <th>${message(code: 'consumo.cuotas.label', default: 'Cuotas')} </th>
                        	
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${consumosImportados}" status="i" var="consumoInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                            <td>
                            <modalbox:createLink url="/GTesoreria/consumo/showPopUp/${consumoInstance.id}" title="Ver Consumo" width="500">${fieldValue(bean: consumoInstance, field: "id")}</modalbox:createLink>
                            </td>
                        
                            <td>${fieldValue(bean: consumoInstance, field: "afiliado.apellidoNombre")}</td>
                        
                            <td><g:formatDate date="${consumoInstance.fecha}" format="MM-yyyy"/></td>
                        
                            <td style="text-align:right"><g:formatNumber number="${consumoInstance?.monto}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
                            
                            <td>${fieldValue(bean: consumoInstance, field: "nroCuota")} / ${fieldValue(bean: consumoInstance, field: "cantCuotas")}</td>
                        	
                        </tr>
                    </g:each>
                    <tr>
                    	<td colspan="3">
                    	&nbsp;
                    	</td>
                    	<td>TOTAL:</td>
                    	<td>${total}</td>
                    	<td>&nbsp;</td>
                    </tr>
                    </tbody>
                </table>
            </div>
         
            </g:if>
            
        </div>
    </body>
</html>
